package main

import "fmt"

func main()  {
	//testMap()
	//testMap2()
	//testMap3()
	//testMap4()
	testMap5()
}

func testMap() {
	var a = map[string]string{"key":"value"}
	a["abc"] = "efg"
	fmt.Println(a)
	a["abc"] = "efg1"
	fmt.Println(a)
	a["abc1"] = "efg"
	fmt.Println(a)
}

func testMap2()  {
	a := make(map[string]map[string]string,100)
	a["key1"] = make(map[string]string)
	a["key1"]["key2"] = "abc"
	a["key1"]["key3"] = "abc"
	a["key1"]["key4"] = "abc"
	a["key1"]["key5"] = "abc"
	fmt.Println(a)
	for i,v :=  range a{
		for i2,v2:=range v{
			fmt.Println(i,i2,v2)
		}
	}
}

func testMap3()  {
	a := make(map[string]map[string]string,100)
	modify(a)
	fmt.Println(a)
}

func modify(strings map[string]map[string]string) {
	_,ok := strings["zhangsan"]
	if !ok{
		strings["zhangsan"] = make(map[string]string)
	}
	strings["zhangsan"]["password"] = "123456"
	strings["zhangsan"]["nickname"] = "pangpang"
}

func testMap4()  {
	a := make(map[string]map[string]string,100)
	a["key1"] = make(map[string]string)
	a["key1"]["key2"] = "abc"
	a["key1"]["key3"] = "abc"
	a["key1"]["key4"] = "abc"
	a["key1"]["key5"] = "abc"

	a["key2"] = make(map[string]string)
	a["key2"]["key2"] = "abc"
	a["key2"]["key3"] = "abc"
	fmt.Println(a)
	fmt.Println(len(a))
	delete(a,"key1")
	fmt.Println(a)
	fmt.Println(len(a))
}

func testMap5()  {
	var a []map[int]int
	a = make([]map[int]int,5)
	if a[0] == nil{
		a[0] = make(map[int]int)
	}
	a[0][10] = 10
	fmt.Println(a)
}



